﻿using System;
using System.Runtime.Serialization;
using EnvDTE;
using Microsoft.Practices.RecipeFramework;

namespace Sixeyed.Guidance.CodeGeneration.References
{
    /// <summary>
    /// Reference for adding recipes to any Visual Studio project
    /// </summary>
    [Serializable]
    public class AnyProjectReference : UnboundRecipeReference
    {
        /// <summary>
        /// Constructor with initial state
        /// </summary>
        /// <param name="template">Template</param>
        public AnyProjectReference(string template) : base(template) { }

        /// <summary>
        /// Gets the reference target description
        /// </summary>
        public override string AppliesTo
        {
            get { return "Any project"; }
        }

        /// <summary>
        /// Returns whether the reference is enabled for a target
        /// </summary>
        /// <param name="target">Target item</param>
        /// <returns>Whether enabled</returns>
        public override bool IsEnabledFor(object target)
        {
            return target is Project;
        }

        #region ISerializable Members

        /// <summary>
        /// Required constructor for deserialization.
        /// </summary>
        protected AnyProjectReference(SerializationInfo info, StreamingContext context) : base(info, context) { }

        #endregion ISerializable Members
    }
}
